package collection;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class SortPoint {
    public static void main(String[] args) {
        List<Point> list = new ArrayList<>();
        list.add(new Point(1, 2));
        list.add(new Point(3, 1));
        list.add(new Point(2, 5));
        list.add(new Point(4, 4));
        System.out.println("list的初始顺序是："+list);

        Collections.sort(list,(o1, o2) ->o2.getY()  - o1.getY()
                //前面的 - 后面的
                //return o1.getX() - o2.getX(); //按照x坐标升序排序
                  //按照y坐标降序排序
        );
        System.out.println("list排序后的顺序是："+list);
    }
}
